package wypozyczalnia.domain;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;
import org.hibernate.annotations.Type;

@Entity
@Table(name = "photo")
public class Photo extends BaseEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Id
	  @GeneratedValue(strategy=GenerationType.AUTO)
	  @Column(updatable=false, name="PHOTO_ID")
	  private Integer idPhoto;

	  @Column(name="photo", nullable=true)
	  @Lob
	  private byte[] photo;

	  @Type(type="org.hibernate.type.NumericBooleanType")
	  @Column(updatable=false)
	  private Boolean mainPhoto;

	  @ManyToOne
	  @JoinColumn(name="person", nullable=true)
	  private Person person;

	  @ManyToOne
	  @JoinColumn(name="movie", nullable=true)
	  private Movie movie;

	  public Photo()
	  {
	  }

	  public Photo(byte[] photo, Boolean mainphoto, Movie movie)
	  {
	    this.photo = photo;
	    this.mainPhoto = Boolean.valueOf(false);
	    this.movie = movie;
	  }

	  public Photo(byte[] photo, Boolean mainphoto, Person person) {
	    this.photo = photo;
	    this.mainPhoto = Boolean.valueOf(false);
	    this.person = person;
	  }

	  public Integer getIdPhoto() {
	    return this.idPhoto;
	  }

	  public void setIdPhoto(Integer idPhoto) {
	    this.idPhoto = idPhoto;
	  }

	  public byte[] getPhoto() {
	    return this.photo;
	  }

	  public void setPhoto(byte[] photo) {
	    this.photo = photo;
	  }

	  public Boolean getMainPhoto() {
	    return this.mainPhoto;
	  }

	  public void setMainPhoto(Boolean mainPhoto) {
	    this.mainPhoto = mainPhoto;
	  }

	  public Person getMovie() {
	    return this.person;
	  }

	  public void setMovie(Movie movie) {
	    this.movie = movie;
	  }

	  public Person getPerson() {
	    return this.person;
	  }

	  public void setPerson(Person person) {
	    this.person = person;
	  }

}
